home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Sound / SoundEffects 0.9.2 / SoundEffects Developer’s Kit / Interfaces / Glue.h < prev    next >
Text File  |  1994-11-21  |  9KB  |  238 lines

  1. // =============================================================================
  2. // SOUNDEFFECTS MODULES HEADER - VERSION 1.0 - NOVEMBER 1994
  3. // ©1994 Alberto Ricci <ricci@pmn.it> <fricci@polito.it>
  4. // Don’t forget to send me any cool effect modules you create!
  5. // This text looks best in monaco 9 font, 4 spaces per tab, no wrapping
  6.  
  7. #ifndef _H_glue
  8. #define _H_glue
  9.  
  10. #if defined(powerc) || defined (__powerc)
  11. #pragma options align=mac68k
  12. #endif
  13.  
  14. // =============================================================================
  15. // MESSAGES (sent to the module):        Corresponding action you must take (Glue.c will handle all this for you)
  16.  
  17. #define    kMsgRun            'Mrun'        //    run the effect without showing any settings dialog.
  18. #define    kMsgSettings    'Mset'        //    let the user change any settings specific to your
  19.                                     //    module, if there are any.
  20. #define    kMsgSettingsRun    'Msar'        //    let the user change any setting, then run the effect.
  21. #define    kMsgHeadersVers    'Mhvr'        //    store the value of kHeadersVersion into the long
  22.                                     //    word pointed to by the GluePtr parameter, then
  23.                                     //    return noErr.
  24. #define    kMsgAbout        'Minf'        //    do whatever you want to describe your effect module.
  25.  
  26. // =============================================================================
  27. // RECORD DEFINITIONS:
  28.  
  29. typedef struct                        // There is one of these structures for each channel in the sound.
  30. {
  31.     Handle            chan;            // You will normally access the channel handle like this:
  32.                                     //    myChannelHandle = (*modInfo->hands)[channelNumber].chan;
  33.                                     // with channelNumber ranging from 0 to modInfo->numChans - 1.
  34.     unsigned long    size;            // size is the number of bytes, not samples.
  35. } SEChanRec, *SEChanPtr, **SEChanHandle;
  36.  
  37. typedef struct
  38. {
  39.     long            outVol[1];
  40. } ChanAttrsRec, *ChanAttrsPtr, **ChanAttrsHandle;
  41.  
  42. #define    kHeadersVersion    1            //    current version of callbacks
  43.  
  44. typedef struct                        //    items marked as read-only cannot be changed directly
  45. {                                    //    by the module. Use the callbacks instead.
  46.     short            version;
  47.     short            refNum;
  48.     StringPtr        name;
  49.     
  50.     WindowPtr        parentWind;
  51.     SEChanHandle    hands;
  52.     ChanAttrsHandle    outModes;        //    read-only
  53.     unsigned long    selSt;
  54.     unsigned long    selEnd;
  55.     unsigned long    loopSt;
  56.     unsigned long    loopEnd;
  57.     Fixed            rate;
  58.     short            bps;
  59.     short            numChans;
  60.     short            firstSelCh;
  61.     short            lastSelCh;
  62.     Byte            baseFreq;
  63.     
  64.     short            doExtend;
  65.     short            units;
  66. } ModParamsRec, *ModParamsPtr, **ModParamsHandle;
  67.  
  68. typedef struct ModAboutRec
  69. {
  70.     short            version;
  71.     short            refNum;
  72.     WindowPtr        parentWind;
  73.     StringHandle    name;
  74. } ModAboutRec, *ModAboutPtr, **ModAboutHandle;
  75.  
  76. typedef struct
  77. {
  78.     short    type;
  79.     ProcPtr    proc;
  80.     long    param;
  81. } ItemInfoRec, *ItemInfoPtr, **ItemInfoHandle;
  82.  
  83.  
  84. // This structure is used by the GetMachineInfo callback.
  85.  
  86. #define    kCurMachineRecVers    1
  87. typedef struct MachineRec
  88. {
  89.     short        machineRecVers;                    //  kCurMachineRecVers
  90.     Boolean        hasFPU;                            //  01
  91.     Boolean        hasColorQD;                        //  02  all these flags are automatically set up by SoundEffects
  92.     Boolean        has32BitQD;                        //  03  so the modules don't have to call Gestalt all the time
  93.     Boolean        hasQuickTime;                    //  04
  94.     Boolean        hasSoundManager3;                //  05
  95.     Boolean        hasSoundInputDevice;            //  06
  96.     Boolean        hasStereoOutput;                //  07
  97.     Boolean        hasStereoInput;                    //  08
  98.     Boolean        mixesStereoOutputToMono;        //  09
  99.     Boolean        hasPlayAndRecord;                //  10
  100.     Boolean        has16BitSoundIO;                //  11
  101.     Boolean        hasMultipleChannels;            //  12
  102. } MachineRec, *MachinePtr, **MachineHandle;
  103.  
  104.  
  105. // Declare a struct for the module’s settings in your header file as
  106. // struct ModSettingsRec {…}; the struct should contain any parameters needed by your
  107. // effect when it runs, and it can be retrieved by the module with the glue routine
  108. // LoadEffectSettings.
  109. typedef struct ModSettingsRec ModSettingsRec;
  110. typedef ModSettingsRec *ModSettingsPtr;
  111. typedef ModSettingsRec **ModSettingsHandle;
  112.  
  113.  
  114. typedef pascal void (*ModSetInitProcPtr)(DialogPtr);
  115.  
  116.  
  117. typedef struct GlueRec
  118. {
  119.     short                glueVers;
  120.     
  121.     //    version 1 callbacks
  122.     
  123.     /*    progress bar */
  124.     pascal void            (*ModSetupProgress) (ModParamsPtr myInfo, short *timeToCallProgress, StringHandle textStr);
  125.     pascal OSErr        (*ModShowProgress) (unsigned long cur, unsigned long total, short *timeToCallProgress, Boolean canCancel);
  126.     pascal void            (*ModCloseProgress) (void);
  127.     pascal WindowPtr    (*GetProgressWind) (void);
  128.     
  129.     /*    effect preferences */
  130.     pascal OSErr        (*LoadEffectSettings) (StringPtr signature, ModSettingsHandle *myHand);
  131.     pascal OSErr        (*SaveEffectSettings) (StringPtr signature, ModSettingsHandle *myHand);
  132.     pascal short        (*GetEffectSettingsRefNum) (void);
  133.     
  134.     /*    user setups */
  135.     pascal OSErr        (*ModDoSettingsDialog) (ModParamsPtr modInfo, ItemInfoHandle myItemInfo,
  136.                             Boolean withSetups, ModalFilterProcPtr custFilterProc,
  137.                             ProcPtr custItemHandler, ModSetInitProcPtr initProc);
  138.     pascal short        (*ModGetSetupsNumber) (ModParamsPtr modInfo);
  139.     pascal OSErr        (*ModGetSetup) (ModParamsPtr modInfo, short num, Handle *mySetup);
  140.     pascal OSErr        (*ModGetSetupName) (ModParamsPtr modInfo, short num, StringPtr myStr);
  141.     pascal OSErr        (*ModSetSetup) (ModParamsPtr modInfo, short num, Handle mySetup, StringPtr myName);
  142.     pascal OSErr        (*ModDeleteSetup) (ModParamsPtr modInfo, DialogPtr myDlog, short itemNum, short num);
  143.     pascal OSErr        (*ModSetupCreateMenu) (ModParamsPtr modInfo, DialogPtr myDlog, short itemNum);
  144.     pascal OSErr        (*ModSetupSwitchCustom) (ModParamsPtr modInfo, DialogPtr myDlog, short itemNum, Boolean addCustom);
  145.     
  146.     /*    generic stuff */
  147.     pascal OSErr        (*GetMachineInfo) (MachinePtr *infoPtr);
  148.     pascal short        (*AskDoExtend) (void);
  149.     pascal void            (*ModInitRandSeed) (void);
  150.     
  151.     /*    dialog utilities */
  152.     pascal short        (*ApplWindowsUpdate) (WindowPtr theWind);
  153.     pascal short        (*ApplWindowsActivate) (EventRecord *passEvt);
  154.     pascal void            (*ModConvertToUnits) (ModParamsPtr modInfo, StringPtr destStr, unsigned long srcVal, short newUnits);
  155.     pascal void            (*ModConvertToBytes) (ModParamsPtr modInfo, StringPtr srcStr, unsigned long *destVal, short newUnits);
  156.     
  157.     /*    obtaining information */
  158.     pascal long            (*GetBytesToProcess) (ModParamsPtr myInfo);
  159.     pascal OSErr        (*ModMaxChSize) (ModParamsHandle modData, unsigned long *size);
  160.     pascal OSErr        (*ModMaxRelChSize) (ModParamsHandle modData, unsigned long *size);
  161.     pascal OSErr        (*ModGetPeak) (ModParamsHandle modData, unsigned long *peak, unsigned long *pos);
  162.     pascal void            (*ModGetSampleValueLimits) (short bps, signed long *min, signed long *max);
  163.     pascal unsigned long(*ModGetOffsToSndHeader) (Handle sndHandle);
  164.     pascal unsigned long(*ModGetOffsToSndData) (Handle sndHandle);
  165.     
  166.     /*    utilities */
  167.     pascal Boolean        (*ModToggleInputLevel) (Boolean on);
  168.     pascal OSErr        (*ModDrawWave) (ModParamsPtr modInfo, Rect *bounds, unsigned long maxSize, unsigned long firstByte, unsigned long zoom, short firstCh, short lastCh);
  169.     pascal OSErr        (*ModShowError) (ModParamsPtr modInfo, short errNum, Boolean withCancel);
  170.     
  171.     /*    channels stuff */
  172.     pascal OSErr        (*ModAddNewChannel) (ModParamsHandle modData, short where);
  173.     pascal OSErr        (*ModDelChannel) (ModParamsHandle modData, short chan);
  174.     pascal short        (*ModGetChannelPan) (ChanAttrsHandle chAttrs, short channel, Boolean leftOne);
  175.     pascal void            (*ModSetChannelPan) (ChanAttrsHandle chAttrs, short channel, short leftPan, short rightPan);
  176.     
  177.     /*    simple actions */
  178.     pascal OSErr        (*ModSilenceOut) (ModParamsHandle modData, short chSt, short chEnd, unsigned long st, unsigned long end);
  179.     
  180.     /*    resampling */
  181.     pascal OSErr        (*ModResampleSoundBits) (ModParamsHandle modData, short newBps);
  182.     pascal OSErr        (*ModResampleSoundRate) (ModParamsHandle modData, Fixed newRate);
  183.     
  184.     /*    new document creation */
  185.     pascal OSErr        (*ModNewDocument) (ModParamsHandle *modData);
  186.     pascal OSErr        (*ModChangeNewDocument) (ModParamsHandle modData);
  187. } GlueRec, *GluePtr, **GlueHandle;
  188.  
  189.  
  190. // =============================================================================
  191. // ROUTINE PROTOTYPES:
  192.  
  193. pascal OSErr    main            (OSType message, ModParamsPtr modInfo, GluePtr glue68k, GluePtr gluePPC);
  194.  
  195. pascal OSErr    effect            (ModParamsPtr modInfo, GluePtr glue, ModSettingsHandle *prefs);
  196. pascal OSErr    settings        (ModParamsPtr modInfo, GluePtr glue, ModSettingsHandle *prefs);
  197. pascal OSErr    about            (ModAboutPtr modInfo);
  198.  
  199. pascal OSErr    GetModSettings    (ModParamsPtr modInfo, GluePtr glue, ModSettingsHandle *prefs);
  200.  
  201. long            SetupEffectWorld    (void);
  202. void            RestoreEffectWorld    (long world);
  203.  
  204.  
  205. // =============================================================================
  206. // RESULT CODES (returned by the module):
  207.  
  208. enum
  209. {
  210.     kModNoError = noErr,            //  no error
  211.     
  212.     kModCancel = userCanceledErr,    //    return this when the module didn’t do anything.
  213.     
  214.     kModGenericError = 1,            //    return positive results if the module left the data untouched.
  215.     kModNotEnoughMemory,
  216.     kModCouldntLoadMyRes = 23,
  217.     kModUnknownMessage = 30,
  218.                                     //    SoundEffects will look for a 'STR#' resource, ID=1000, in the module.
  219.                                     //    If the string with index equal to the absolute value of the returned
  220.                                     //    result.
  221.     
  222.     kTellGenericError = -1,            //  return negative results if the module changed some data.
  223.     kTellNotEnoughMemory = -2,
  224.     kTellCouldntLoadMyRes = -23
  225. };
  226.  
  227. // returned by the settings routine:
  228. enum
  229. {
  230.     kModHasNoSettings = 1
  231. };
  232.  
  233.  
  234. #if defined(powerc) || defined (__powerc)
  235. #pragma options align=reset
  236. #endif
  237.  
  238. #endif